package com.meimeixia.pattern.factory.simple_factory;

public class SimpleCoffeeFactory {

    public Coffee createCoffee(String type) {
        // 声明Coffee类型的变量，根据不同类型创建不同的Coffee子类对象
        Coffee coffee;
        switch (type){
            case "american":
                coffee = new AmericanCoffee();
                break;
            case "latte":
                coffee = new LatteCoffee();
                break;
            default:
                throw new RuntimeException("对不起，您所点的咖啡没有");
        }
        return coffee;
    }
}
